import { PayloadUser } from '@libs/common/decorator';
import { IndexInterceptor } from '@libs/common/interceptors';
import { Body, Controller, Post, UseInterceptors } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';

import { AttendanceService } from './attendance.service';
import {
  FindAttendanceDto,
  IndexAttendanceDto,
  StatisticsAttendanceDto,
  SyncAttendanceDto,
  TodayAttendanceDto,
} from './dto/attendance.dto';

@ApiTags('考勤管理')
@Controller('hr/attendance')
export class AttendanceController {
  constructor(private readonly attendanceService: AttendanceService) {}

  @Post('index')
  @UseInterceptors(new IndexInterceptor())
  index(@Body() dto: IndexAttendanceDto) {
    return this.attendanceService.index(dto);
  }

  @Post('statistics')
  statistics(@Body() dto: StatisticsAttendanceDto) {
    return this.attendanceService.statistics(dto);
  }

  // 导入考勤数据
  // @Post('import')
  // import(@Body('date') date?: string) {
  //   return this.attendanceService.import(date);
  // }

  @Post('find')
  find(@Body() dto: FindAttendanceDto) {
    return this.attendanceService.find(dto);
  }

  @Post('sync')
  sync(@Body() dto: SyncAttendanceDto) {
    return this.attendanceService.sync(dto);
  }

  @Post('today')
  today(@Body() dto: TodayAttendanceDto, @PayloadUser() user: SC.User.Info) {
    return this.attendanceService.today(dto, user);
  }
}
